package me.magicall.db.sql;

import me.magicall.db.sql.select.ResultField;
import me.magicall.db.sql.table.AbsDomainable;

/**
 * 可以带有as的sql元素。
 * 
 * @author MaGiCalL
 */
public abstract class AsableElement<D extends Domain> extends AbsDomainable<D> {

	protected AsableElement() {
		super();
	}

	protected AsableElement(final String name) {
		super(name);
	}

	protected AsableElement(final String name, final D domain) {
		super(name, domain);
	}

	public HasAs as(final As as) {
		final AbsHasAs asable = newAsedWrapper();
		asable.setToSqlable(this);
		asable.setAs(as);
		return asable;
	}

	/**
	 * 注:只有table需要重写这个方法
	 * 
	 * @return
	 */
	protected AbsHasAs newAsedWrapper() {
		return new ResultField();
	}

	public HasAs as(final String asName) {
		return as(new As(asName));
	}

}